package com.learn._0fundamental;

/**
 * 递归print和循环print造成的空间复杂度的差异
 */
public class PrintN {


    public static void main(String[] args) {

        int times = 1;
        int n = 10000;

        long start = System.currentTimeMillis();
        while(times -- > 0){
            //printNRecurse(n);
            printNCycle(n);
        }
        long end = System.currentTimeMillis();

        System.out.println("共用时"+(end - start));



    }



    private static void printNRecurse(int n){
        if(n != 0){
            printNRecurse(n - 1);
            System.out.println(n);
        }
    }

    private static void printNCycle(int n){
        int start = 1;
        while(start <= n){
            System.out.println(start++);
        }
    }



}
